package javacvtest.sqladminserver.Controller;



import javacvtest.sqladminserver.result.Result;

import javacvtest.sqladminserver.DTO.SqlDatabaseDTO;
import javacvtest.sqladminserver.DTO.SqlUrlDTO;
import javacvtest.sqladminserver.VO.SqlResultVO;
import javacvtest.sqladminserver.service.SqlService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/sql")
@RestController
public class sqlConnectController {

    @Autowired
    private SqlService sqlService;

    @PostMapping("/check")
    public Result<List<String>> sqlConnection(@RequestBody SqlUrlDTO sqlUrlDTO){

        
        return sqlService.checkSql(sqlUrlDTO);
    }

    @PostMapping("/result")
    public SqlResultVO getSqlReslut(@RequestBody SqlDatabaseDTO sqlDatabaseDTO){
        SqlResultVO reslutVO = sqlService.getSqlReslut(sqlDatabaseDTO);
        return reslutVO;
    }

//    @PostMapping("/close")
//    public Result<Boolean> sqlConnectionClose(@RequestParam String request){
//        sqlConnectService.close();
//        return Result.success();
//    }
}
